import java.util.*;

public class Test {
}
class Solution {
    public List<String> removeComments(String[] source) {
        List<String> ans = new ArrayList<>();
        StringBuilder tmp = new StringBuilder();
        boolean inBlock = false;
        for(String x : source){
            for(int i=0; i<x.length(); i++){
                if(inBlock){
                    if(i+1<x.length() && x.charAt(i) == '*' && x.charAt(i+1) == '/'){
                        inBlock = false;
                        i++;
                    }
                }else{
                    if(i+1<x.length() && x.charAt(i) == '/' && x.charAt(i+1) == '*'){
                        inBlock = true;
                        i++;
                    }else if(i+1<x.length() && x.charAt(i)=='/' && x.charAt(i+1) == '/'){
                        break;
                    }else{
                        tmp.append(x.charAt(i));
                    }
                }
            }
            if(!inBlock && tmp.length()>0){
                ans.add(tmp.toString());
                tmp.setLength(0);
            }
        }
        return ans;
    }
}
class Solution1 {
    public int countStudents(int[] students, int[] sandwiches) {
        Stack<Integer> stack = new Stack<>();
        Queue<Integer> queue = new LinkedList<>();
        for(int i=sandwiches.length-1; i>=0; i--){
            stack.push(sandwiches[i]);
        }
        for(int i=0; i<students.length; i++){
            queue.offer(students[i]);
        }
        while(!stack.isEmpty()){
            while(!stack.isEmpty() && stack.peek() == queue.peek()){
                stack.pop();
                queue.poll();
            }
            int count = 0;
            while(!stack.isEmpty() && stack.peek() != queue.peek()){
                int ret = queue.poll();
                queue.offer(ret);
                count++;
                if(count == queue.size()){
                    return count;
                }
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(100 == 100);
        System.out.println(1000 == 1000);
    }
}
class Solution2 {
    int dfs(TreeNode root,int cnt){
        if(root==null){
            return 0;
        }
        if(root.left==null&&root.right==null){
            cnt^=(1<<root.val);
            return (cnt==0||(cnt&(cnt-1))==0)?1:0;
        }
        return dfs(root.left,cnt^(1<<root.val))+dfs(root.right,cnt^(1<<root.val));
    }
    public int pseudoPalindromicPaths (TreeNode root) {
        return dfs(root,0);
    }
}